function [ numB1, numB2 ] = CountColorPixel( image, mask, minB1, maxB1, minB2, maxB2, minSat, minVal )
%CountColorPixel: Counts two amounts of pixels lying in specific areas of
%image

if minB1 > maxB1
    helpMinB1 = 0;
    helpMaxB1 = 1;
else
    helpMinB1 = minB1;
    helpMaxB1 = maxB1;
end

if minB2 > maxB2
    helpMinB2 = 0;
    helpMaxB2 = 1;
else
    helpMinB2 = minB2;
    helpMaxB2 = maxB2;
end

hsv = rgb2hsv(image);
h = hsv(:,:,1);
s = hsv(:,:,2);
v = hsv(:,:,3);
h(mask == 1) = -1;

sumPix = sum((mask(:) == 0));

b1 = zeros(size(h));
b2 = zeros(size(h));
b1(((h > minB1 & h < helpMaxB1) | (h > helpMinB1 & h < maxB1)) & s > minSat & v > minVal) = 1;
b2(((h > minB2 & h < helpMaxB2) | (h > helpMinB2 & h < maxB2)) & s > minSat & v > minVal) = 1;

numB1 = sum(b1(:)) / sumPix;
numB2 = sum(b2(:)) / sumPix;

end

